﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Shake.Framework.View;
using Shake.Framework.Context;
using Shake.Framework.Attributes;
namespace Shake.Web.Controllers
{
    [Grant("开发管理")]
    [Theme("LayUIAdmin")]
    public class CodeController : Controller
    {
        [Grant("预览文件")]
        public new ActionResult View(string file)
        {
            if (string.IsNullOrEmpty(file))
            {
                return this.Shake(new PostResult("找不到文件", file));
            }
            var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file.TrimStart('/'));
            if (!System.IO.File.Exists(path))
            {
                return this.Shake(new PostResult("找不到文件", file));
            }
            var code = System.IO.File.ReadAllText(path);
            return this.Shake(new PostResult { Data = code });
        }
    }
}